More aggresively move_into_the_past for tests
authorAlex Crichton <alex@alexcrichton.com>
Wed, 5 Nov 2014 22:00:38 +0000 (14:00 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 5 Nov 2014 22:33:34 +0000 (14:33 -0800)
Right now we're accidentally not actually leveraging this function well in some
tests due to this sequence of events:

1. The tests run at time X, building artifacts that remember the fingerprint is
   at time X.
2. The entire project is moved back one hour to (X-1).
3. A new file is created, at time X (second-level resolution on some systems).
4. On a rebuild, the maximum mtime is still X (due to the new file).

For this reason there are some more calls to move_into_the_past() to push files
back another hour after they've been created to make sure the maximum mtime is
(X-1), or something different than X.

tests/test_cargo_compile_custom_build.rs
tests/test_cargo_features.rs

index b81f83a77e4bcb3cd19c82da3b9095e2b0598509..4fa32fa635b5c359ed4d6000f681a53c4a7ee257 100644 (file)
@@ -366,6 +366,7 @@ test!(only_rerun_build_script {
     p.root().move_into_the_past().unwrap();
 
     File::create(&p.root().join("some-new-file")).unwrap();
+    p.root().move_into_the_past().unwrap();
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("build").arg("-v"),
                 execs().with_status(0)
@@ -421,6 +422,7 @@ test!(rebuild_continues_to_pass_env_vars {
     p.root().move_into_the_past().unwrap();
 
     File::create(&p.root().join("some-new-file")).unwrap();
+    p.root().move_into_the_past().unwrap();
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("build").arg("-v"),
                 execs().with_status(0));
@@ -445,6 +447,7 @@ test!(testing_and_such {
     p.root().move_into_the_past().unwrap();
 
     File::create(&p.root().join("src/lib.rs")).unwrap();
+    p.root().move_into_the_past().unwrap();
 
     assert_that(p.process(cargo_dir().join("cargo")).arg("test").arg("-vj1"),
                 execs().with_status(0)
index cc0e8ab5a9a09c65bd35a4edeb9bc69492b801df..23569e4cdd8c3d7b109f534902e5eeaad28d959f 100644 (file)
@@ -1,5 +1,5 @@
 use support::{project, execs, cargo_dir};
-use support::COMPILING;
+use support::{COMPILING, FRESH};
 use support::paths::PathExt;
 use hamcrest::assert_that;
 
@@ -529,8 +529,11 @@ test!(many_features_no_rebuilds {
 ", compiling = COMPILING, dir = p.url()).as_slice()));
     p.root().move_into_the_past().unwrap();
 
-    assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
-                execs().with_status(0).with_stdout(""));
+    assert_that(p.process(cargo_dir().join("cargo")).arg("build").arg("-v"),
+                execs().with_status(0).with_stdout(format!("\
+{fresh} a v0.1.0 ([..])
+{fresh} b v0.1.0 ([..])
+", fresh = FRESH).as_slice()));
 })
 
 // Tests that all cmd lines work with `--features ""`